home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple Developer Connection Student Program
/
ADC Tools Sampler CD Disk 3 1999.iso
/
Cool Demos, SDKs, & Tools
/
Demos⁄Tools⁄Offers
/
Eiffel for CW beta 3
/
EiffelS2
/
LIBRARY
/
MOTEL
/
Resources.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-04-26
|
5KB
|
220 lines
/*------------------------------------------------------------------*/
/* Eiffel/S II MacOS Runtime */
/*------------------------------------------------------------------*/
/* Author : Ian Joyner */
/* Release : 1.0 */
/* Date : Dec. 1997 */
/* Copyright : Ian Joyner */
/*------------------------------------------------------------------*/
/********************************************************************/
/* */
/* RESOURCESs */
/* */
/********************************************************************/
#include <Resources.h>
#include <Eiffel2.h>
#include "MOTEL.h"
INTEGER platform_resource_current_file ()
{
return CurResFile ();
}
void platform_resource_set_file (INTEGER ref_num)
{
UseResFile (ref_num);
}
INTEGER platform_resource_home_file (Handle res)
{
return HomeResFile (res);
}
INTEGER platform_resource_count_types (BOOLEAN b)
{
return (b)? Count1Types () : CountTypes ();
}
INTEGER platform_resource_count_resources (ResType t, BOOLEAN b)
{
return (b)? Count1Resources (t) : CountResources (t);
}
void platform_resource_file_create (INTEGER v_ref_num, INTEGER parID,
ConstStr255Param name,
ConstStr255Param creator,
ConstStr255Param type,
INTEGER script_tag)
{
FSSpec fs;
union
{
ResType r;
char c [4];
} ct;
union
{
ResType r;
char c [4];
} ty;
fs.vRefNum = v_ref_num;
fs.parID = parID;
strcpy (fs.name, name);
ct.c [0] = creator [0]; ct.c [1] = creator [1]; ct.c [2] = creator [2]; ct.c [3] = creator [3];
ty.c [0] = type [0]; ty.c [1] = type [1]; ty.c [2] = type [2]; ty.c [3] = type [3];
FSpCreateResFile (&fs, ct.r, ty.r, script_tag);
}
INTEGER platform_resource_file_open (INTEGER v_ref_num, INTEGER parID,
POINTER name, CHARACTER permission)
{
FSSpec fs;
fs.vRefNum = v_ref_num;
fs.parID = parID;
strcpy (fs.name, name);
return FSpOpenResFile (&fs, permission);
}
INTEGER platform_resource_error ()
{
return ResError ();
}
INTEGER platform_resource_file_attributes (INTEGER ref_num)
{
return GetResFileAttrs (ref_num);
}
void platform_resource_file_set_attributes (INTEGER ref_num, INTEGER new_attributes)
{
SetResFileAttrs (ref_num, new_attributes);
}
void platform_resource_file_update (INTEGER ref_num)
{
UpdateResFile (ref_num);
}
void platform_resource_file_close (INTEGER ref_num)
{
CloseResFile (ref_num);
}
ResType platform_resource_type (ConstStr255Param t)
{
union
{
ResType r;
char c [4];
} ct;
ct.c [0] = t [0]; ct.c [1] = t [1]; ct.c [2] = t [2]; ct.c [3] = t [3];
return ct.r;
}
Handle platform_resource_get (ResType t, INTEGER id, BOOLEAN b, BOOLEAN ROM)
{
if (ROM)
return RGetResource (t, id);
else
return (b)? Get1Resource (t, id) : GetResource (t, id);
}
Handle platform_resource_get_by_name (ResType t, ConstStr255Param n, BOOLEAN b)
{
Str255 scratch;
strcpy (scratch, n);
c2pstr ((char *)scratch); /* This might not be right if string is loaded from a resource */
return (b)? Get1NamedResource (t, scratch) : GetNamedResource (t, scratch);
}
Handle platform_resource_get_by_index (ResType t, INTEGER ix, BOOLEAN b)
{
return (b)? Get1IndResource (t, ix) : GetIndResource (t, ix);
}
ResType platform_resource_get_type_by_index (INTEGER ix, BOOLEAN b)
{
ResType t;
if (b)
Get1IndType (&t, ix);
else
GetIndType (&t, ix);
}
INTEGER platform_resource_get_id (Handle rh)
{
short the_id;
int the_type;
GetResInfo (rh, &the_id, &the_type, &scratch_string);
return the_id;
}
POINTER platform_resource_get_name (Handle rh)
{
short the_id;
int the_type;
GetResInfo (rh, &the_id, &the_type, &scratch_string);
return &scratch_string;
}
void platform_resource_set_info (Handle rh, INTEGER id, ConstStr255Param name)
{
strcpy (scratch_string, name);
c2pstr ((char *)scratch_string); /* This might not be right if string is loaded from a resource */
SetResInfo (rh, id, scratch_string);
}
INTEGER platform_resource_get_attributes (Handle rh)
{
return GetResAttrs (rh);
}
void platform_resource_set_attributes (Handle rh, INTEGER attrs)
{
SetResAttrs (rh, attrs);
}
INTEGER platform_resource_unique_id (ResType t, BOOLEAN b)
{
return (b)? Unique1ID (t) : UniqueID (t);
}
/*
void platform_resource_load (Handle rh)
{
LoadResource (rh);
}
void platform_resource_changed (Handle rh)
{
ChangedResource (rh);
}
void platform_resource_write (Handle rh)
{
WriteResource (rh);
}
void platform_resource_release (Handle rh)
{
ReleaseResource (rh);
}
*/